package com.demo.function.spring.httpinterface.service;

import com.alibaba.fastjson.JSON;
import com.demo.function.spring.httpinterface.WebClientMiyaHttpInterfaceClient;
import com.demo.model.entity.User;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

@Slf4j
@Service
public class WebClientHttpInterfaceService {

    @Resource
    private WebClientMiyaHttpInterfaceClient webClientMiyaHttpInterfaceClient;

    /**
     * 异步调用Miya服务延迟接口，底层使用WebClient
     * @param time 延迟时间，单位秒
     */
    public Mono<User> proceeLongTime(Long time) {
        return webClientMiyaHttpInterfaceClient.processLongTime(time);
    }

    public User modifyUser(User user) {
        User result = webClientMiyaHttpInterfaceClient.modifyUser(user);
        log.info("modifyUser接口返回结果：{}", JSON.toJSONString(result));
        return result;
    }
}
